#include <stdio.h>
#include <stdlib.h>

struct student {
    int num;
    char name[20];
    int c;
    int j;
    int p;
    double ave;
};

int main() {
    int n;
    FILE *file;
    scanf("%d", &n);
    struct student a[n];

    for (int i = 0; i < n; i++) {
        scanf("%d %s %d %d %d", &a[i].num, a[i].name, &a[i].c, &a[i].j, &a[i].p);
        a[i].ave = (a[i].c + a[i].j + a[i].p) / 3.0;
    }

    if ((file = fopen("stud.dat", "wb+")) == NULL) {
        printf("File open error!\n");
        exit(1);  
    }

    
    fwrite(&n, sizeof(int), 1, file);


    fwrite(a, sizeof(struct student), n, file);

    
    if (fclose(file) != 0) {
        printf("File close error!\n");
        exit(1);  
    }

    return 0;
}
